All Questions
9 questions
2votes
0answers
79views
is there an alternate way of using the waitfornextupdate function from the react-hooks library in react 18
so i was working on a jest test file that is testing a hook that deals with session management and the project has moved forward to react 18 which made the testing library, react-hooks, deprecated. I ...
0votes
1answer
63views
React (v16.14.0) Testing w/ Enzyme/Jest: Component state rendering data on fetch that is inside a useEffect
I am having issue with testing a component that makes a fetch call inside a useEffect. What's happening is that, state is being updated but the component is not rendering the data from the fetch call ...
2votes
0answers
114views
Error: Uncaught [TypeError: createKeccakHash is not a function]
I am trying to use web3js external calls in jest test. Previously i was able to get data, but the error thrown was can not console response after the end of test something like this, although i was ...
1vote
0answers
738views
How to test react component mocking fetch api?
I'm trying to test a react component where a fetch call occurs. The component: class SearchResults extends React.Component<{ tag: string; setSpinner: (value: boolean) => void }> { state: ...
1vote
1answer
1kviews
How to render and test a component with mocked api
I've just set up a mock test of an api call but now am wanting to know how I could actually test this mocked data against my component. My api call will render a random set of information hence the ...
37votes
9answers
13kviews
Jest encountered an unexpected token + react markdown
I'm getting an error when trying to run my test file (I'm using react typescript) ● Test suite failed to run Jest encountered an unexpected token Jest failed to parse a file. This happens ...
2votes
1answer
2kviews
Jest: Continue testing when expected error is thrown on button click
I am trying to test a React error boundary (with react-error-boundary library) by creating a button (to test that the code inside the library is displayed) and when clicked I want to verify that the ...
0votes
1answer
3kviews
Mock a class function used inside a React component
I'm trying to mock a function which is called inside my react component. Here is an exemple, with the function getContent(). How could I set my own return value in the test ? Component.test.tsx : ...
4votes
1answer
5kviews
How to use manual mock with typescript, react and jest?
I am trying to use jest to mock the return value of a hook used by a React component, but I can't get it to work. Consider the price tag component. All it does is render the price returned from the ...